﻿using Testudo.Core;
using Testudo.Models;
using Testudo.ViewModels;

namespace Testudo.Services;

internal class ScenarioService : IScenarioService
{
    public ScenarioService(
        IRepository<ScenarioConfig, ScenarioConfigVM, CreateScenarioConfigVM, UpdateScenarioConfigVM> repository)
    {
        Repository = repository;
    }

    private IRepository<ScenarioConfig, ScenarioConfigVM, CreateScenarioConfigVM, UpdateScenarioConfigVM> Repository
    {
        get;
    }

    public async Task<List<ScenarioConfigVM>> GetList()
    {
        return await Repository.GetListAsync();
    }

    public async Task<ScenarioConfigVM> Get(Guid id)
    {
        return await Repository.GetAsync(id);
    }

    public async Task<ScenarioConfigVM> Create(CreateScenarioConfigVM vm)
    {
        return await Repository.CreateAsync(vm);
    }

    public async Task<ScenarioConfigVM> Update(UpdateScenarioConfigVM vm)
    {
        return await Repository.UpdateAsync(vm);
    }

    public async Task<ScenarioConfigVM> Patch(PatchData vm)
    {
        return await Repository.PatchAsync(vm);
    }

    public async Task<bool> Delete(DeleteScenarioConfigVM vm)
    {
        return await Repository.DeleteAsync(vm.Id);
    }
}